import instance from '@/utils/request'

/**
 * 获取月卡列表
 * @param { page, pageSize} params
 * @returns
 */
export function getCardListAPI(params) {
  return instance({
    url: '/parking/card/list',
    params
  })
}

/**
 * 添加月卡
 * @param { personName,phoneNumber,carNumber,carBrand,cardStartDate,cardEndDate,paymentAmount,paymentMethod  } params
 * @returns
 */
export function addCardAPI({
  personName,
  phoneNumber,
  carNumber,
  carBrand,
  cardStartDate,
  cardEndDate,
  paymentAmount,
  paymentMethod
}) {
  return instance({
    url: '/parking/card',
    method: 'post',
    data: {
      personName,
      phoneNumber,
      carNumber,
      carBrand,
      cardStartDate,
      cardEndDate,
      paymentAmount,
      paymentMethod
    }
  })
}

/**
 * 获取月卡详情
 * @data {id}
 * @returns
 */
export function getCardDetailAPI(id) {
  return instance({
    url: `/parking/card/detail/${id}`
  })
}

/**
 * 更新月卡
 * @param {personName,phoneNumber,carNumber,carBrand,cardStartDate,cardEndDate,paymentAmount,paymentMethod,carInfoId,rechargeId} data
 * @returns
 */
export function updateCardAPI(data) {
  return instance({
    url: '/parking/card/edit',
    method: 'PUT',
    data
  })
}

/**
 * 删除月卡
 * @param {*} id
 * @returns
 */
export function delCardAPI(id) {
  return instance({
    url: `/parking/card/${id}`,
    method: 'DELETE'
  })
}

/**
 * 批量删除月卡
 * @param {*} ids [1,2,3]
 * @returns
 */
export function delAllCardAPI(ids) {
  return instance({
    url: `/parking/card/${ids.join(',')}`,
    method: 'DELETE'
  })
}
